﻿/*
==================================================================
    注意：此文件为Auto代码，不可手动修改【在用绳检测状态】
==================================================================
*/

namespace Services
{
    /// <summary>
    /// Auto在用绳检测状态
    /// </summary>
    public abstract class AutoCheckWireropeStatusMonitorMapping : BaseMapping<CheckWireropeStatusMonitor, CheckWireropeStatusMonitorModel, CheckWireropeStatusMonitorFilterModel>
    {
        public AutoCheckWireropeStatusMonitorMapping(ICurrentUser currentUser)
            : base(currentUser) { }

        #region 读数据
        /// <summary>
        /// 读数据，从Entity对象转成Model对象
        /// </summary>
        /// <param name="entity">Entity对象</param>
        /// <returns></returns>
        public override CheckWireropeStatusMonitorModel Entity2Model(CheckWireropeStatusMonitor entity)
        {
            CheckWireropeStatusMonitorModel model = new CheckWireropeStatusMonitorModel();

            model.CheckWireropeStatusMonitorID = entity.CheckWireropeStatusMonitorID;
            model.GroupInfoID = entity.GroupInfoID;
            model.UsingWireropeID = entity.UsingWireropeID;
            model.La = entity.La;
            model.Dia = entity.Dia;
            model.Lma = entity.Lma;
            model.Summary = entity.Summary;
            model.NianJu = entity.NianJu;
            model.LaVal = entity.LaVal;
            model.DiaVal = entity.DiaVal;
            model.LmaVal = entity.LmaVal;
            model.SummaryVal = entity.SummaryVal;
            model.NianJuVal = entity.NianJuVal;

            return model;
        }
        #endregion

        #region 写数据
        /// <summary>
        /// 写数据，从Model对象转换成Entity对象
        /// </summary>
        /// <param name="model">ViewModel对象</param>
        /// <returns></returns>
        public override CheckWireropeStatusMonitor Model2Entity(CheckWireropeStatusMonitorModel model)
        {
            CheckWireropeStatusMonitor entity = new CheckWireropeStatusMonitor();

            entity.CheckWireropeStatusMonitorID = model.CheckWireropeStatusMonitorID;
            entity.GroupInfoID = model.GroupInfoID;
            entity.UsingWireropeID = model.UsingWireropeID;
            entity.La = model.La;
            entity.Dia = model.Dia;
            entity.Lma = model.Lma;
            entity.Summary = model.Summary;
            entity.NianJu = model.NianJu;
            entity.LaVal = model.LaVal;
            entity.DiaVal = model.DiaVal;
            entity.LmaVal = model.LmaVal;
            entity.SummaryVal = model.SummaryVal;
            entity.NianJuVal = model.NianJuVal;

            return entity;
        }
        #endregion

        #region 搜索条件转换
        /// <summary>
        /// 搜索条件转换，从FilterModel对象转换成Where对象
        /// </summary>
        /// <param name="filterModel">FilterModel对象</param>
        /// <returns></returns>
        public override Expressionable<CheckWireropeStatusMonitor> FilterModel2Where(CheckWireropeStatusMonitorFilterModel filterModel)
        {
            var where = base.FilterModel2Where(filterModel);

            //编号
            if (filterModel._CheckWireropeStatusMonitorID.HasValue)
            {
                where = where.And(x => x.CheckWireropeStatusMonitorID == filterModel._CheckWireropeStatusMonitorID.Value);
            }
            if (filterModel._CheckWireropeStatusMonitorIDs.IsNotEmpty() && filterModel._CheckWireropeStatusMonitorIDs.Count > 0)
            {
                where = where.And(x => filterModel._CheckWireropeStatusMonitorIDs.Contains(x.CheckWireropeStatusMonitorID));
            }
            if (filterModel._NotCheckWireropeStatusMonitorIDs.IsNotEmpty() && filterModel._NotCheckWireropeStatusMonitorIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotCheckWireropeStatusMonitorIDs.Contains(x.CheckWireropeStatusMonitorID));
            }

            //集团
            if (filterModel._GroupInfoID.HasValue)
            {
                where = where.And(x => x.GroupInfoID == filterModel._GroupInfoID.Value);
            }
            if (filterModel._GroupInfoIDs.IsNotEmpty() && filterModel._GroupInfoIDs.Count > 0)
            {
                where = where.And(x => filterModel._GroupInfoIDs.Contains(x.GroupInfoID));
            }
            if (filterModel._NotGroupInfoIDs.IsNotEmpty() && filterModel._NotGroupInfoIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotGroupInfoIDs.Contains(x.GroupInfoID));
            }

            //在用绳
            if (filterModel._UsingWireropeID.HasValue)
            {
                where = where.And(x => x.UsingWireropeID == filterModel._UsingWireropeID.Value);
            }
            if (filterModel._UsingWireropeIDs.IsNotEmpty() && filterModel._UsingWireropeIDs.Count > 0)
            {
                where = where.And(x => filterModel._UsingWireropeIDs.Contains(x.UsingWireropeID));
            }
            if (filterModel._NotUsingWireropeIDs.IsNotEmpty() && filterModel._NotUsingWireropeIDs.Count > 0)
            {
                where = where.And(x => !filterModel._NotUsingWireropeIDs.Contains(x.UsingWireropeID));
            }

            return where;
        }
        #endregion
    }
}

